<?php
function user_ListCats($bclassid, $showMore)
{
    if ($bclassid != 10) {
        user_ListMenu($bclassid, $showMore);
        return;
    }
    global $empire, $dbtbpre, $public_r;// classpath 为地址
    $sql = $empire->query("select classid, classname, bclassid, islast, classpath, classurl from {$dbtbpre}enewsclass where bclassid='$bclassid' and wburl='' order by myorder,classid"); // 判断是否有类别记录
    $num = $empire->num1($sql);
    if ($num == 0 && $bclassid == 0) // 无记录
    {
        echo $GLOBALS ['notrecordword'];
        return "";
    }
    if ($num == 0) {
        return '';
    }
    echo "<ul id=\"div$bclassid" . "Menu\" class=\"flexdropdownmenu\">\n";
    $i = 1;
    while ($r = $empire->fetch($sql)) { // 如果不是终极栏目，显示其子目录
        if (empty ($r [islast]) && $showMore) {
            echo "<li class=\"TitleLink\">\n";
            echo "<a href=\"$public_r[newsurl]$r[classpath] \"> $r[classname] </a>\n";
            echo "</li>\n";
            user_ListCatsLeve2($r [classid], $showMore);
        } else { // 终极栏目
            echo "<li class=\"DetailLink\">\n";
            echo "<a href=\"$public_r[newsurl]$r[classpath] \">  $r[classname]  </a>\n";
            if ($bclassid == 10) {
                echo "<div></div>\n";
            }
            echo "</li>\n";

        }
        $i += 1;
    }
    echo "</ul>\n";
}

/**
 * 第二级栏目
 * @param unknown_type $bclassid
 * @param unknown_type $showMore
 */
function user_ListCatsLeve2($bclassid, $showMore)
{
    global $empire, $dbtbpre,  $public_r;// classpath 为地址
    $sql = $empire->query("select c.classid, c.classname, c.bclassid, c.islast, c.classpath, c.classurl,c.classimg ,t.tbname from {$dbtbpre}enewsclass c,{$dbtbpre}enewstable t  where c.tid=t.tid and c.bclassid='$bclassid'  order by myorder,classid"); // 判断是否有类别记录
    $num = $empire->num1($sql);
    if ($num == 0 && $bclassid == 0) // 无记录
    {
        echo $GLOBALS ['notrecordword'];
        return "";
    }
    if ($num == 0) {
        return '';
    }

    $i = 1;
    while ($r = $empire->fetch($sql)) { // 如果不是终极栏目，显示其子目录

        echo "<li class=\"DetailLink\">\n";
        echo "<a href=\" $public_r[newsurl]$r[classpath] \"> $r[classname] </a>\n";

        echo "<ul id=\"DetailLinkLevel3\"> \n";
        echo "<div id=\"DetailLinkLevel3-content\">\n";
        echo "<span class=\"text\">";
        echo "$r[classname]";
        echo "</span>\n";
        echo "<span class=\"image-product\">\n";
        echo "<img src=\"$r[classimg]\" width='145px' height='50px' />\n";
        echo "</span>\n";
        user_ListCatsLeve3($r, $r[classpath],$r[tbname]);
        echo"</div>";
        echo"</ul>\n";
        echo "</li>\n";
        $i += 1;
    }
}

/**
 * 第三级栏目
 * @param unknown_type $bclassid
 * @param unknown_type $showMore
 */
function user_ListCatsLeve3($r, $classpath,$tbname)
{
    global $empire, $dbtbpre, $public_r; // classpath 为地址
    echo "<div class=\"clearzero\"></div>\n";

    if (empty ($r[islast])) { //子栏目
        $sql3 = $empire->query("select c.classid, c.classname, c.bclassid, c.islast, c.classpath, c.classurl,c.classimg,t.tbname from {$dbtbpre}enewsclass c,{$dbtbpre}enewstable t where c.tid=t.tid and  c.bclassid=\"$r[classid]\" and c.wburl='' order by c.myorder,c.classid"); // 判断是否有类别记录
        $num = $empire->num1($sql3);
        if ($num == 0 && $r[classid] == 0) // 无记录
        {
            return "";
        }
        if ($num == 0) {
            return "";
        }
        while ($r = $empire->fetch($sql3)) {
            echo "<div id=\"DetailLinkLevel3-Product\">\n";
            echo "<a href=\"\">$r[classname]</a>";
            user_ListCatsProduct($r[classid], $r[classpath],$r[tbname]);
            //echo "<img src=\"$public_r[newsurl]skin/involuser/images/img-DetailLinkLevel3-Product-line.gif\" alt=\"line\" />";
            echo "<div class=\"clearzero\"></div>\n";
            echo "</div>";
        }
    } else { //无子栏目
        echo "<div id=\"DetailLinkLevel3-Product\">\n";
        user_ListCatsProduct($r[classid], $r[classpath],$r[tbname]);
        //echo "<img src=\"$public_r[newsurl]skin/involuser/images/img-DetailLinkLevel3-Product-line.gif\" alt=\"line\" />";
        echo "<div class=\"clearzero\"></div>\n";
        echo "</div>";
    }


}

/**
 * 展示产品
 * @param unknown_type $bclassid 栏目ID
 * @param unknown_type $showNum  展示产品数量
 */
function user_ListCatsProduct($classid, $classpath,$tbname)
{
    global $empire,$public_r, $dbtbpre; // classpath 为地址
    $sql = $empire->query("select  id, classid,title,newspath  from {$dbtbpre}ecms_$tbname where classid='$classid'  order by truetime desc"); // 判断是否有类别记录
    $num = $empire->num1($sql);
    if ($num > 0) //有记录
    {
        while ($r1 = $empire->fetch($sql)) {
            echo " <a href=\"$public_r[newsurl]"."$classpath"."/"."$r1[newspath]"."/"."$r1[id]".".html\" class=\"item\">$r1[title]</a>\n";
        }
    }
}


/**
 * 无限极导航menu
 * @param unknown_type $bclassid
 * @param unknown_type $showMore
 * @return string
 */
function user_ListMenu($bclassid, $showMore)
{
    global $empire, $dbtbpre,$public_r; //	classpath 为地址
    $sql = $empire->query("select classid, classname, bclassid, islast, classpath, classurl from {$dbtbpre}enewsclass where bclassid='$bclassid' and wburl='' order by myorder,classid"); //	判断是否有类别记录
    $num = $empire->num1($sql);
    if ($num == 0 && $bclassid == 0) //无记录
    {
        echo $GLOBALS['notrecordword'];
        return "";
    }
    if ($num == 0) {
        return '';
    }
    echo "<ul id=\"div$bclassid" . "Menu\" class=\"flexdropdownmenu\">\n";
    $i = 1;
    while ($r = $empire->fetch($sql)) { //	如果不是终极栏目，显示其子目录
        if (empty($r[islast]) && $showMore) {
            echo "<li class='flexdropdownmenucmm'><a class='Item' href=$public_r[newsurl]$r[classpath]>" . $r[classname] . '</a>';
            user_ListCats($r[classid], $showMore);
        } else {
            echo "<li class='flexdropdownmenucmm'><a class='Item' href=$public_r[newsurl]$r[classpath]>" . $r[classname] . '</a>';
        }
        echo '</li>';
        $i += 1;
    }
    echo "</ul>\n";
}

/**
 * tab产品目录
 * @param $bclassid
 * @param $showMore
 */
function user_tabMenu($bclassid)
{
    global $empire, $dbtbpre; //	classpath 为地址
    $sql = $empire->query("select classid, classname, bclassid, islast, classpath, classurl from {$dbtbpre}enewsclass where bclassid='$bclassid' and wburl='' order by myorder,classid"); //	判断是否有类别记录
    $num = $empire->num1($sql);
    if ($num == 0 && $bclassid == 0) //无记录
    {
        return "";
    }
    echo "<div id=\"tab_menu\" class=\"tab_menu\">\n";
    echo "<ul>\n";
    $i = 1;
    while ($r = $empire->fetch($sql)) {
        if (empty($r[islast])) {
            if($i==1){
                echo " <li  class=\"selected\">";
            }else {
                if($i==5){
                    echo " <li class=\"last\">";
                }else{
                echo " <li>";
                }
            }
            echo " <a href='$r[classpath]' class=\"a$i\">";
            echo "$r[classname]";
            echo "</a>";
            echo "</li>\n";
            $i++;
        }
    }
    echo "</ul>\n";
    echo "</div>\n";
}

/** 产品第二级别小类
 * @param $bclassid
 * @param $showMore
 * @return string
 */
function user_Tab2Menu($bclassid)
{
    global $empire, $dbtbpre; //	classpath 为地址
    $sql = $empire->query("select classid, classname, bclassid, islast, classpath, classurl from {$dbtbpre}enewsclass where bclassid='$bclassid' and wburl='' order by myorder,classid"); //	判断是否有类别记录
    $num = $empire->num1($sql);
    echo "<div class=\"tab_box\" >\n";
    $i = 1;
    while ($r = $empire->fetch($sql)) {
        $sql1 = $empire->query("select e.classid, e.classname, e.bclassid, e.islast,t.tbname, e.classpath, e.classurl from {$dbtbpre}enewsclass e ,{$dbtbpre}enewstable t where e.tid=t.tid and  bclassid=$r[classid] and wburl='' order by myorder,classid"); //	判断是否有类别记录
        if($i==1){
            echo "<div class=\"tab-content-list b$i\">\n";
        }else{
            echo "<div class=\"tab-content-list hide b$i\">\n";
        }
        while ($r1 = $empire->fetch($sql1)) {
            echo"<ul>\n";
            echo "<h4>$r1[classname]</h4>";
                user_TabProduct($r1[classid],$r1[classpath],$r1[tbname]);
            echo"</ul>\n";

        }
        echo "</div>\n";
        $i++;
    }
    echo "</div>\n";
}

/** 产品第三级别小类
 * @param $bclassid
 * @param $showMore
 * @return string
 */
function user_Tab3Menu($bclassid)
{
    global $empire, $dbtbpre; //	classpath 为地址
    $sql = $empire->query("select classid, classname, bclassid, islast, classpath,tid, classurl from {$dbtbpre}enewsclass where bclassid='$bclassid' and wburl='' order by myorder,classid"); //	判断是否有类别记录
    $num = $empire->num1($sql);
    $r=0;
    while ($r = $empire->fetch($sql)) { //	如果不是终极栏目，显示其子目录
        if (!empty($r[islast])) {
            echo"<li>\n";
            echo"<a href=\"$r[classurl]\">$r[classname]</a>";
            echo"</li>\n";
        }

    }
}

function user_TabProduct($bclassid,$classpath,$tbname)
{
    global $empire, $dbtbpre; //	classpath 为地址
    $sql = $empire->query("select id, classid,title,newspath  from {$dbtbpre}ecms_$tbname where classid='$bclassid'  order by truetime desc  limit 5 "); // 判断是否有类别记录
    $num = $empire->num1($sql);
    if ($num == 0 || $bclassid == 0) //无记录
    {
        return "";
    }

    $i = 1;
    while ($r = $empire->fetch($sql)) { //
        echo "<li>\n";
        echo "<a href=\"$classpath"."/"."$r[newspath]"."/"."$r[id]".".html\" alt=\"$r[id]\">";
        echo "$r[title]";
        echo "</a>";
        echo "</li>";
    }
}

/**
 * 产品1明细产品子表
 * @param $bclassid
 */
function user_Product1Sub($id,$classid){
    global $empire, $dbtbpre, $public_r;// classpath 为地址
    $standardsql = $empire->query("select *  from {$dbtbpre}ecms_standard where p_id='$id' and  classid='$classid' order by no asc "); // 判断是否有类别记录
    $documentsql=$empire->query("select *  from {$dbtbpre}ecms_document where p_id='$id' and classid='$classid'");
    $documentsql1=$empire->query("select *  from {$dbtbpre}ecms_document where p_id='$id' and classid='$classid'");


    echo "<div  class=\"prdtabsContent\" id='modelSpecifications' style=\"display: none;\">\n";
    echo "<div style=\"float: left;\">";
    echo "<table width=\"95%\" class=\"Specfication\">";
    echo "<tbody>";
    while ($r1 = $empire->fetch($standardsql)) { // 如果有数据输出
      // 终极栏目
            echo "<tr>\n";
            echo "<td class='title'>$r1[standard_name]</td>";
            echo "<td >$r1[standard_note]</td>";
            echo "</tr>";
    }
    echo "</tbody>\n";
    echo "</table>\n";
    echo "</div>";
    echo "</div>";

    echo "<div class='prdtabsContent' id='modelDownload' style='display: none;'>\n";
    echo "<div style='float: left;'>\n";

    echo "<table class='InformationTable'>\n";
    echo "<tbody><tr>\n";
    echo "<th class='TitleClass'>驱动</th>\n";
    echo "<th class='TitleClass'></th>";
    echo "<th class='TitleClass'></th>";
    echo "<th class='TitleClass'></th>";
    echo "<th class='TitleClass'></th>";
    echo "</tr>\n";
    echo "<tr>";
    echo "<th>日期</th>";
    echo "<th>说明</th>";
    echo "<th>版本</th>";
    echo "<th>操作系统</th>";
    echo "<th>下载</th>";
    echo "</tr>\n";
    while ($r1 = $empire->fetch($documentsql)) {
        if($r1[type]=="driver"){
       echo "<tr>";
       echo "<td>$r1[document_date]</td>";
       echo "<td>$r1[note]</td>";
       echo "<td>$r1[edition]</td>";
       echo "<td>$r1[os]</td>";
       if($r1[file]==null){
            echo "<td>下载</td>";
        }else{
           $filesize=$r1[file_size]/(1024*1024);
           $filesize=round($filesize,3);
           $filesize=$filesize."MB";
           echo "<td><a href='$r1[file]'>$filesize</a></td>";
       }
       echo "</tr>";
        }
    }
    echo "</tbody>\n";
    echo "</table>\n";

    echo "<table class='InformationTable'>\n";
    echo "<tbody><tr>\n";
    echo "<th class='TitleClass'>文档</th>\n";
    echo "<th class='TitleClass'></th>";
    echo "<th class='TitleClass'></th>";
    echo "<th class='TitleClass'></th>";
    echo "</tr>\n";
    echo "<tr>";
    echo "<th>日期</th>";
    echo "<th>说明</th>";
    echo "<th>版本</th>";
    echo "<th>下载</th>";
    echo "</tr>\n";

    while ($r2 = $empire->fetch($documentsql1)) {
        if($r2[type]=="document"){
        echo "<tr>";
        echo "<td>$r2[document_date]</td>";
        echo "<td>$r2[note]</td>";
        echo "<td>$r2[edition]</td>";
        if($r2[file]==null){
            echo "<td>下载</td>";
        }else{
            $filesize=$r2[file_size]/(1024*1024);
            $filesize=round($filesize,3);
            $filesize=$filesize."MB";
            echo "<td><a href='$r2[file]'>$filesize</a></td>";
        }
        echo "</tr>";
        }
    }
    echo "</tbody>\n";
    echo "</table>\n";
    echo "</div>\n";
    echo "</div>\n";



}

?>